require('../../assets/js/property.js')
require('../../assets/font/font_3852666_7r0dooui378/iconfont.css')
require('../../assets/css/index.less')
require('./login.less')
//引入请求工具
const request = require('../../assets/js/requers')
//dom加载完毕
window.onload = () => {
    $('#submitBtn').addEventListener('click', () => {
        let errMsg = ''
        if (!/^1[3-9]\d{9}$/.test($('#phoneIpt').value)) {
            errMsg = '请输入正确手机号码'
            //console.log('errMsg :>> ', errMsg);
        }  else if (!/^\w{3,6}$/.test($('#psdIpt').value)) {
            errMsg = '请输入3-6位密码'
            //console.log('errMsg :>> ', errMsg);
        } else {
            //验证成功发送请求
            //console.log('验证成功发送请求 :>> ', '验证成功发送请求');
            request.post('/api/user/login',{
                account: $('#phoneIpt').value,
                password:$('#psdIpt').value

            }).then(res=>{
                let {errno,data}=res.data
                if(errno===0){
                    //alert('登录成功')
                    localStorage.setItem('token','Bearer '+ data.token)
                   location.href='./home.html'
                } else{
                    alert(message)
                }
            })
               
        }
    })
}